﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepCultivation.API.AddliCation.SheepManagement;
using SheepCultivation.Common.Domain.Week3;
using SheepCultivation.Common.Dto;
using SheepCultivation.Enum;
using Yitter.IdGenerator;

namespace SheepCultivation.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SheepManagementsController : ControllerBase
    {
        public readonly IMediator mediator;

        public SheepManagementsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        #region 下拉框 羊只类型
        /// <summary>
        /// 下拉框羊只类型
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("SheepTypesList")]
        public async Task<Result> Handle(SheepTypesSeachCommon request)
        {
            return await mediator.Send(request);
        }
        #endregion

        #region 下拉框羊只耳号
        /// <summary>
        /// 下拉框羊只耳号
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("AuricleBind")]
        public async Task<Result> Handle(DeathManagementListCommon request)
        {
            return await mediator.Send(request);
        }
        #endregion

        #region 羊只死亡反填
        /// <summary>
        /// 羊只死亡反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("DeathManagementBack")]
        public async Task<Result> Handle(DeathManagementBackCommon request)
        {
            return await mediator.Send(request);
        }
        #endregion

        #region 羊只死亡新增
        /// <summary>
        /// 羊只死亡新增
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("DeathManagementAdds")]
        public async Task<Result> Handle(DeathManagementCreateCommon request)
        {
            return await mediator.Send(request);
        }
        #endregion

        #region 羊只死亡列表
        /// <summary>
        /// 羊只死亡列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("DeathManagementLists")]
        public async Task<Result> Handle(DeathManagementSeachCommon request)
        {
            return await mediator.Send(request);
        }
        #endregion

        #region 羊只淘汰新增
        /// <summary>
        /// 羊只淘汰新增
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("EliminateAdds")]
        public async Task<Result> Handle(EliminatesCreateCommon request)
        {
            return await mediator.Send(request);
        }
        #endregion

        #region 生成流水号
        /// <summary>
        /// 生成流水号
        /// </summary>
        /// <returns></returns>
        [HttpPost("GetYitterId")]
        public IActionResult GetYitterId()
        {
            List<string> list = new List<string>();
            for (int i = 0; i <= 10; i++)
            {
                string id = YitIdHelper.NextId().ToString();
                list.Add(id);
            }
            return Ok(list);
        }
        #endregion

        #region 雪花ID
        /// <summary>
        /// 雪花ID
        /// </summary>
        /// <returns></returns>
        [HttpPost("GetId")]
        public string GetId()
        {
            return YitIdHelper.NextId().ToString();
        }
        #endregion
    }
}
